asm
  ld sp,$FFEF
  end asm

#include "./library/pacmandelay.bas"
#include "./library/smsrnd.bas"

dim eee as uinteger at $F012
dim seed as uinteger at $F014
dim ee0 as uinteger at $F010
dim ee1 as uinteger at $F01A
dim ee2 as uinteger at $F016
dim ee3 as uinteger at $F018
dim ecsp as ubyte at $F01C
dim ecsq as ubyte at $F01E
dim ex0 as uinteger at $F020
dim ey0 as uinteger at $F022
dim ej0 as uinteger at $F024
dim ej1 as uinteger at $F026

sub olibochuputchar (txp1 as uinteger,typ1 as uinteger,tch1 as ubyte,tat1 as ubyte):
  poke $8000+(txp1*32)+(typ1 bxor 31),tch1
  poke $8400+(txp1*32)+(typ1 bxor 31),tat1
  end sub

for eee=$8000 to $87FF
  seed=smsrnd(seed)
  poke eee,seed
  next
for eee=$F400 to $F47F
  seed=smsrnd(seed)
  poke eee,seed
  next



for ee0=0 to 31
  for ee1=0 to 31
    ee2=seed:seed=smsrnd(seed)
    ee2=seed:seed=smsrnd(seed)
    olibochuputchar(ee1,ee0,seed band 3,ee2 band 15)
    'pacmandelay(1000)   
    next:next

for ee0=0 to 15
  for ee1=0 to 15
    olibochuputchar(ee1+14,ee0+15,ee0*16+ee1,0)
    next:next

ex0=8:ey0=8
eee=0
do


olibochuputchar(6,1,48+(eee mod 10),0)
olibochuputchar(5,1,48+((int(eee/10)) mod 10),0)
olibochuputchar(4,1,48+((int(eee/100)) mod 10),0)
olibochuputchar(3,1,48+((int(eee/1000)) mod 10),0)
olibochuputchar(2,1,48+((int(eee/10000)) mod 10),0)

ee0=peek($A000) bxor $FF
olibochuputchar(6,3,48+(ee0 mod 10),0)
olibochuputchar(5,3,48+((int(ee0/10)) mod 10),0)
olibochuputchar(4,3,48+((int(ee0/100)) mod 10),0)

ee0=peek($A001) bxor $FF
olibochuputchar(6,4,48+(ee0 mod 10),0)
olibochuputchar(5,4,48+((int(ee0/10)) mod 10),0)
olibochuputchar(4,4,48+((int(ee0/100)) mod 10),0)

ex0=ex0+((ee0 band 1)/1)-((ee0 band 2)/2)
ey0=ey0+((ee0 band 4)/4)-((ee0 band 8)/8)
olibochuputchar(ex0,ey0,eee,0)

ee0=peek($A002) bxor $FF
olibochuputchar(6,5,48+(ee0 mod 10),0)
olibochuputchar(5,5,48+((int(ee0/10)) mod 10),0)
olibochuputchar(4,5,48+((int(ee0/100)) mod 10),0)


eee=eee+1
loop

'-------------------------------------------------------------------------------

do:loop


for eee=$8000 to $83FF
  seed=smsrnd(seed)
  poke eee,eee
  'pacmandelay(10000)
  next




do:loop


'static ADDRESS_MAP_START( olibochu_map, AS_PROGRAM, 8, olibochu_state )
'AM_RANGE(0x0000, 0x7fff) AM_ROM
'AM_RANGE(0x8000, 0x83ff) AM_RAM_WRITE(olibochu_videoram_w) AM_SHARE("videoram")
'AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(olibochu_colorram_w) AM_SHARE("colorram")
'AM_RANGE(0x9000, 0x903f) AM_RAM //???
'AM_RANGE(0x9800, 0x983f) AM_RAM //???
'AM_RANGE(0xa000, 0xa000) AM_READ_PORT("IN0")
'AM_RANGE(0xa001, 0xa001) AM_READ_PORT("IN1")
'AM_RANGE(0xa002, 0xa002) AM_READ_PORT("IN2")
'AM_RANGE(0xa003, 0xa003) AM_READ_PORT("DSW0")
'AM_RANGE(0xa004, 0xa004) AM_READ_PORT("DSW1")
'AM_RANGE(0xa005, 0xa005) AM_READ_PORT("DSW2")
'AM_RANGE(0xa800, 0xa801) AM_WRITE(sound_command_w)
'AM_RANGE(0xa802, 0xa802) AM_WRITE(olibochu_flipscreen_w)    /* bit 6 = enable sound? */
'AM_RANGE(0xf400, 0xf41f) AM_RAM AM_SHARE("spriteram")
'AM_RANGE(0xf440, 0xf47f) AM_RAM AM_SHARE("spriteram2")
'AM_RANGE(0xf000, 0xffff) AM_RAM
'ADDRESS_MAP_END

'static ADDRESS_MAP_START( olibochu_sound_map, AS_PROGRAM, 8, olibochu_state )
'AM_RANGE(0x0000, 0x1fff) AM_ROM
'AM_RANGE(0x6000, 0x63ff) AM_RAM
'AM_RANGE(0x7000, 0x7000) AM_READ(soundlatch_byte_r) /* likely ay8910 input port, not direct */
'AM_RANGE(0x7000, 0x7001) AM_DEVWRITE("aysnd", ay8910_device, address_data_w)
'AM_RANGE(0x7004, 0x7004) AM_WRITENOP //sound filter?
'AM_RANGE(0x7006, 0x7006) AM_WRITENOP //irq ack?
'ADDRESS_MAP_END

'-------------------------------------------------------------------------------


